using ASP;
using HoWave.Web;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Agriculture : HoWave_Root, IRequiresSessionState
{
	protected UserControls_cmpy_Top Top1;
	protected DataList dlProductHits1;
	protected DataList dlProductHits2;
	protected DataList dlProductHits3;
	protected DataList dlProductHits4;
	protected Repeater repPic;
	protected DataList dlProduct1F;
	protected DataList dlProduct2F;
	protected UserControls_CMYP_Foot Foot1;
	protected HtmlForm form1;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			string classId = "543";
			this.dlProduct1F.DataSource = this.GetProductByClassID(classId);
			this.dlProduct1F.DataBind();
			string classId2 = "139";
			this.dlProduct2F.DataSource = this.GetProductByClassID(classId2);
			this.dlProduct2F.DataBind();
			this.dlProductHits1.DataSource = this.GetProductHitsByClassID("131");
			this.dlProductHits1.DataBind();
			this.dlProductHits2.DataSource = this.GetProductHitsByClassID("502");
			this.dlProductHits2.DataBind();
			this.dlProductHits3.DataSource = this.GetProductHitsByClassID("503");
			this.dlProductHits3.DataBind();
			this.dlProductHits4.DataSource = this.GetProductHitsByClassID("506");
			this.dlProductHits4.DataBind();
			this.repPic.DataSource = this.GetProductPromoteImg();
			this.repPic.DataBind();
		}
	}
	protected DataTable GetProductByClassID(string classId)
	{
		string sql = "select top 8 ProductID,ProductImageUrl,ProductName,StandPrice from dbo.HLShop_Product where ClassID=" + Convert.ToInt32(classId) + " order by ProductID desc";
		return this.conn.GetDataTable(sql);
	}
	protected DataTable GetProductHitsByClassID(string classId)
	{
		string sql = "select top 3  ProductID,dbo.HLShop_Product.ShopID,SalerID,Hits,ProductImageUrl,ProductName,StandPrice,ShopName from dbo.HLShop_Product inner join dbo.HLShop_Shop on dbo.HLShop_Product.ShopID=dbo.HLShop_Shop.ShopID order by Hits desc";
		return this.conn.GetDataTable(sql);
	}
	protected DataTable GetProductPromoteImg()
	{
		string sql = "select top 3 ProductID,ProductImageUrl,ProductName,BeginDate,EndDate from dbo.HLShop_Product";
		return this.conn.GetDataTable(sql);
	}
	public string GetStr(int num, string strName)
	{
		string result;
		if (strName.Length > num)
		{
			result = strName.Substring(0, num) + "...";
		}
		else
		{
			result = strName;
		}
		return result;
	}
	public string GetPruductImg(object obj)
	{
		string result;
		if (!string.IsNullOrEmpty(obj.ToString()))
		{
			result = obj.ToString();
		}
		else
		{
			result = "Skin/CommStyle/images/noneimg.jpg";
		}
		return result;
	}
}
